﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace H
{
	// Token: 0x02000230 RID: 560
	public class H_StyleData
	{
		// Token: 0x06000F4A RID: 3914 RVA: 0x00061398 File Offset: 0x0005F598
		public H_StyleData(string assetBundle)
		{
			this.assetBundle = assetBundle;
			string text = assetBundle.Substring(assetBundle.LastIndexOf("/") + 1);
			this.id = text.ToUpper();
			this.CheckState();
			AssetBundleController assetBundleController = new AssetBundleController();
			assetBundleController.OpenFromFile(GlobalData.assetBundlePath, assetBundle);
			TextAsset text2 = assetBundleController.LoadAsset<TextAsset>(this.id + "_Data");
			TagText tagText = new TagText(text2);
			foreach (TagText.Element element in tagText.Elements)
			{
				if (element.Tag == "StyleData")
				{
					this.LoadStyleData(element);
				}
				else if (element.Tag == "Camera")
				{
					this.LoadCamera(element);
				}
				else if (element.Tag == "IK")
				{
					this.LoadIK(element);
				}
				else if (element.Tag == "Light")
				{
					this.LoadLight(element);
				}
				else
				{
					GlobalData.Debug_LogError("不明的元素:" + element.Tag);
				}
			}
			assetBundleController.Close(false);
		}

		// Token: 0x06000F4B RID: 3915 RVA: 0x00061524 File Offset: 0x0005F724
		private void LoadStyleData(TagText.Element element)
		{
			element.GetVal(ref this.name, "name", 0);
			string valOriginal = element.Attributes["type"].valOriginal;
			if (valOriginal == "挿入")
			{
				this.type = H_StyleData.TYPE.INSERT;
			}
			else if (valOriginal == "奉仕")
			{
				this.type = H_StyleData.TYPE.SERVICE;
			}
			else if (valOriginal == "愛撫")
			{
				this.type = H_StyleData.TYPE.PETTING;
			}
			else
			{
				GlobalData.Debug_LogError("类型不明:" + valOriginal + " id:" + this.id);
			}
			string empty = string.Empty;
			if (element.GetVal(ref empty, "member", 0))
			{
				if (empty.Equals("pair", StringComparison.OrdinalIgnoreCase))
				{
					this.member = H_StyleData.MEMBER.PAIR;
				}
				else if (empty.Equals("m1f1", StringComparison.OrdinalIgnoreCase) || empty.Equals("f1m1", StringComparison.OrdinalIgnoreCase))
				{
					this.member = H_StyleData.MEMBER.PAIR;
				}
				else if (empty.Equals("m2f1", StringComparison.OrdinalIgnoreCase) || empty.Equals("f1m2", StringComparison.OrdinalIgnoreCase))
				{
					this.member = H_StyleData.MEMBER.M2F1;
				}
				else if (empty.Equals("m3f1", StringComparison.OrdinalIgnoreCase) || empty.Equals("f1m3", StringComparison.OrdinalIgnoreCase))
				{
					this.member = H_StyleData.MEMBER.M3F1;
				}
				else if (empty.Equals("m4f1", StringComparison.OrdinalIgnoreCase) || empty.Equals("f1m4", StringComparison.OrdinalIgnoreCase))
				{
					this.member = H_StyleData.MEMBER.M4F1;
				}
				else if (empty.Equals("m1f2", StringComparison.OrdinalIgnoreCase) || empty.Equals("f2m1", StringComparison.OrdinalIgnoreCase))
				{
					this.member = H_StyleData.MEMBER.M1F2;
				}
			}
			this.detailFlag = H_StyleData.DetailFromString(element.GetAttribute("detail"));
			this.initiative = H_StyleData.InitiativeFromString(element.GetAttribute("initiative"));
			element.GetVal(ref this.insertDelay, "insertDelay", 0);
			string empty2 = string.Empty;
			element.GetVal(ref empty2, "position", 0);
			if (empty2 == "床")
			{
				this.position = H_StyleData.POSITION.FLOOR;
			}
			else if (empty2 == "壁")
			{
				this.position = H_StyleData.POSITION.WALL;
			}
			else if (empty2 == "椅子")
			{
				this.position = H_StyleData.POSITION.CHAIR;
			}
			else if (empty2 == "特殊")
			{
				this.position = H_StyleData.POSITION.SPECIAL;
			}
			else
			{
				this.position = H_StyleData.POSITION.FLOOR;
			}
			if (this.member == H_StyleData.MEMBER.M4F1)
			{
				if (this.state == H_StyleData.STATE.RESIST)
				{
					this.position = H_StyleData.POSITION.FIVE_RESIST;
				}
				else if (this.state == H_StyleData.STATE.FLOP)
				{
					this.position = H_StyleData.POSITION.FIVE_FLOP;
				}
				else if (this.state == H_StyleData.STATE.WEAKNESS)
				{
					this.position = H_StyleData.POSITION.FIVE_WEAKNESS;
				}
			}
			TagText.Attribute attribute = element.GetAttribute("noInsMale");
			if (attribute != null)
			{
				for (int i = 0; i < attribute.ValsNum; i++)
				{
					int num = int.Parse(attribute.vals[i]);
					this.noInsMale |= 1 << num;
				}
			}
			element.GetVal(ref this.map, "map", 0);
			if (this.detailFlag == 0)
			{
				if (this.type == H_StyleData.TYPE.INSERT)
				{
					GlobalData.Debug_LogError("没有细节:" + this.id);
				}
				else
				{
					GlobalData.Debug_Log("没有细节:" + this.id);
				}
			}
		}

		// Token: 0x06000F4C RID: 3916 RVA: 0x000618A8 File Offset: 0x0005FAA8
		private static int DetailFromString(TagText.Attribute detailAttr)
		{
			if (detailAttr == null)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < detailAttr.ValsNum; i++)
			{
				string a = detailAttr.vals[i];
				for (int j = 0; j < H_StyleData.DetailNames.Length; j++)
				{
					if (a == H_StyleData.DetailNames[j])
					{
						num |= 1 << j;
					}
				}
			}
			return num;
		}

		// Token: 0x06000F4D RID: 3917 RVA: 0x00061918 File Offset: 0x0005FB18
		private static H_StyleData.INITIATIVE InitiativeFromString(TagText.Attribute attr)
		{
			if (attr == null)
			{
				return H_StyleData.INITIATIVE.FAIR;
			}
			if (attr.valOriginal == "男")
			{
				return H_StyleData.INITIATIVE.MALE;
			}
			if (attr.valOriginal == "女")
			{
				return H_StyleData.INITIATIVE.FEMALE;
			}
			if (attr.valOriginal == "-")
			{
				return H_StyleData.INITIATIVE.FAIR;
			}
			GlobalData.Debug_LogError("Initiative不明:" + attr.valOriginal);
			return H_StyleData.INITIATIVE.FAIR;
		}

		// Token: 0x06000F4E RID: 3918 RVA: 0x00061988 File Offset: 0x0005FB88
		private void LoadCamera(TagText.Element element)
		{
			this.camera = new IllusionCameraResetData();
			element.GetVal(ref this.camera.pos.x, "pos", 0);
			element.GetVal(ref this.camera.pos.y, "pos", 1);
			element.GetVal(ref this.camera.pos.z, "pos", 2);
			element.GetVal(ref this.camera.eul.x, "eul", 0);
			element.GetVal(ref this.camera.eul.y, "eul", 1);
			element.GetVal(ref this.camera.eul.z, "eul", 2);
			element.GetVal(ref this.camera.dis, "dis", 0);
		}

		// Token: 0x06000F4F RID: 3919 RVA: 0x00061A68 File Offset: 0x0005FC68
		private void LoadIK(TagText.Element element)
		{
			string empty = string.Empty;
			element.GetVal(ref empty, "anime", 0);
			IK_DataList ik_DataList;
			if (empty.Length > 0)
			{
				ik_DataList = new IK_DataList();
				this.alternativeIK.Add(empty, ik_DataList);
			}
			else
			{
				ik_DataList = this.baseIK;
			}
			TagText.Attribute attribute = element.GetAttribute("ik");
			if (attribute != null && attribute.vals.Count % 4 == 0)
			{
				for (int i = 0; i < attribute.vals.Count; i += 4)
				{
					string ikChara = attribute.vals[i];
					string ikPart = attribute.vals[i + 1];
					string targetChara = attribute.vals[i + 2];
					string targetPart = attribute.vals[i + 3];
					ik_DataList.Add(new IK_Data(ikChara, ikPart, targetChara, targetPart));
				}
			}
		}

		// Token: 0x06000F50 RID: 3920 RVA: 0x00061B48 File Offset: 0x0005FD48
		private void LoadLight(TagText.Element element)
		{
			this.hasLight = true;
			element.GetVal(ref this.lightEuler.x, "eul", 0);
			element.GetVal(ref this.lightEuler.y, "eul", 1);
		}

		// Token: 0x06000F51 RID: 3921 RVA: 0x00061B84 File Offset: 0x0005FD84
		public H_MOUTH GetInsertedMouth()
		{
			if ((this.detailFlag & 1) != 0)
			{
				return H_MOUTH.KISS;
			}
			if ((this.detailFlag & 2) != 0)
			{
				return H_MOUTH.LICK;
			}
			if ((this.detailFlag & H_StyleData.DetailMasking_InMouth) != 0)
			{
				return H_MOUTH.INMOUTH;
			}
			return H_MOUTH.FREE;
		}

		// Token: 0x06000F52 RID: 3922 RVA: 0x00061BB8 File Offset: 0x0005FDB8
		private void CheckState()
		{
			string[] array = this.id.Split(new char[]
			{
				'_'
			}, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 4)
			{
				string text = array[0];
				string text2 = array[1];
				string a = array[2];
				string text3 = array[3];
				if (a == "02")
				{
					this.state = H_StyleData.STATE.WEAKNESS;
				}
				else if (a == "01")
				{
					this.state = H_StyleData.STATE.FLOP;
				}
				else
				{
					this.state = H_StyleData.STATE.RESIST;
				}
			}
			else
			{
				GlobalData.Debug_LogError("命名规则不明的体位数据");
			}
		}

		// Token: 0x06000F53 RID: 3923 RVA: 0x00061C48 File Offset: 0x0005FE48
		public bool IsInMouth()
		{
			return (this.detailFlag & H_StyleData.DetailMasking_InMouth) != 0;
		}

		// Token: 0x04000FEA RID: 4074
		private static readonly string[] DetailNames = new string[]
		{
			"キス",
			"舐め",
			"フェラ",
			"イラマ",
			"性器",
			"アナル",
			"手コキ",
			"パイズリ",
			"胸揉み",
			"オナニー",
			"道具",
			"男拘束",
			"抜けない",
			"女拘束台",
			"女拘束"
		};

		// Token: 0x04000FEB RID: 4075
		public static readonly int DetailMasking_InMouth = 12;

		// Token: 0x04000FEC RID: 4076
		public static readonly int DetailMasking_Bust = 384;

		// Token: 0x04000FED RID: 4077
		public static readonly int DetailMasking_UseMouth = 15;

		// Token: 0x04000FEE RID: 4078
		public string id;

		// Token: 0x04000FEF RID: 4079
		public string name;

		// Token: 0x04000FF0 RID: 4080
		public H_StyleData.MEMBER member;

		// Token: 0x04000FF1 RID: 4081
		public H_StyleData.TYPE type;

		// Token: 0x04000FF2 RID: 4082
		public H_StyleData.STATE state;

		// Token: 0x04000FF3 RID: 4083
		public H_StyleData.POSITION position;

		// Token: 0x04000FF4 RID: 4084
		public string map = string.Empty;

		// Token: 0x04000FF5 RID: 4085
		public string assetBundle;

		// Token: 0x04000FF6 RID: 4086
		public int detailFlag;

		// Token: 0x04000FF7 RID: 4087
		public H_StyleData.INITIATIVE initiative = H_StyleData.INITIATIVE.FAIR;

		// Token: 0x04000FF8 RID: 4088
		public float insertDelay;

		// Token: 0x04000FF9 RID: 4089
		public bool hasLight;

		// Token: 0x04000FFA RID: 4090
		public Vector3 lightEuler;

		// Token: 0x04000FFB RID: 4091
		public int noInsMale;

		// Token: 0x04000FFC RID: 4092
		public IllusionCameraResetData camera;

		// Token: 0x04000FFD RID: 4093
		public IK_DataList baseIK = new IK_DataList();

		// Token: 0x04000FFE RID: 4094
		public Dictionary<string, IK_DataList> alternativeIK = new Dictionary<string, IK_DataList>();

		// Token: 0x02000231 RID: 561
		public enum TYPE
		{
			// Token: 0x04001000 RID: 4096
			INSERT,
			// Token: 0x04001001 RID: 4097
			SERVICE,
			// Token: 0x04001002 RID: 4098
			PETTING,
			// Token: 0x04001003 RID: 4099
			NUM
		}

		// Token: 0x02000232 RID: 562
		public enum STATE
		{
			// Token: 0x04001005 RID: 4101
			UNKNOWN = -1,
			// Token: 0x04001006 RID: 4102
			RESIST,
			// Token: 0x04001007 RID: 4103
			FLOP,
			// Token: 0x04001008 RID: 4104
			WEAKNESS
		}

		// Token: 0x02000233 RID: 563
		public enum DETAIL
		{
			// Token: 0x0400100A RID: 4106
			NONE,
			// Token: 0x0400100B RID: 4107
			KISS,
			// Token: 0x0400100C RID: 4108
			LICK,
			// Token: 0x0400100D RID: 4109
			FELLATIO = 4,
			// Token: 0x0400100E RID: 4110
			IRRUMATIO = 8,
			// Token: 0x0400100F RID: 4111
			VAGINA = 16,
			// Token: 0x04001010 RID: 4112
			ANAL = 32,
			// Token: 0x04001011 RID: 4113
			HAND_JOB = 64,
			// Token: 0x04001012 RID: 4114
			TITTY_FUCK = 128,
			// Token: 0x04001013 RID: 4115
			PET_BUST = 256,
			// Token: 0x04001014 RID: 4116
			ONANIE = 512,
			// Token: 0x04001015 RID: 4117
			TOOL = 1024,
			// Token: 0x04001016 RID: 4118
			MALE_RESTRICT = 2048,
			// Token: 0x04001017 RID: 4119
			DO_NOT_EXTRACT = 4096,
			// Token: 0x04001018 RID: 4120
			FEMALE_HOLDER = 8192,
			// Token: 0x04001019 RID: 4121
			FEMALE_RESITRICT = 16384,
			// Token: 0x0400101A RID: 4122
			NUM = 15
		}

		// Token: 0x02000234 RID: 564
		public enum INITIATIVE
		{
			// Token: 0x0400101C RID: 4124
			FAIR = -1,
			// Token: 0x0400101D RID: 4125
			FEMALE,
			// Token: 0x0400101E RID: 4126
			MALE
		}

		// Token: 0x02000235 RID: 565
		public enum POSITION
		{
			// Token: 0x04001020 RID: 4128
			FLOOR,
			// Token: 0x04001021 RID: 4129
			WALL,
			// Token: 0x04001022 RID: 4130
			CHAIR,
			// Token: 0x04001023 RID: 4131
			SPECIAL,
			// Token: 0x04001024 RID: 4132
			FIVE_RESIST,
			// Token: 0x04001025 RID: 4133
			FIVE_FLOP,
			// Token: 0x04001026 RID: 4134
			FIVE_WEAKNESS
		}

		// Token: 0x02000236 RID: 566
		public enum MEMBER
		{
			// Token: 0x04001028 RID: 4136
			PAIR,
			// Token: 0x04001029 RID: 4137
			M2F1,
			// Token: 0x0400102A RID: 4138
			M3F1,
			// Token: 0x0400102B RID: 4139
			M4F1,
			// Token: 0x0400102C RID: 4140
			M1F2,
			// Token: 0x0400102D RID: 4141
			NUM
		}
	}
}
